;
layui.define([ "table", "form" ], function(exports) {
    tab = layui.table, form = layui.form;
    tab.render({
        elem : "#LAY-web-list",
        url : layui.setter.base + "admin/customer/listJson",
        cols : [ [ {
            field : "custerCode",
            width : 160,
            title : "客户号",
            sort : !0
        }, {
            field : "code",
            title : "用户编号"
        }, {
            field : "custerName",
            title : "用户名称"
        }, {
            field : "userName",
            title : "登录用户名"
        }, {
            field : "legalPerson",
            title : "实名名称"
        }, {
            field : "inCome",
            title : "状态",
            templet : function(data){return data.inCome==1?"消费者":"商家"}
        }, {
            field : "isVerify",
            title : "实名认证",
            templet : function(data){return data.isVerify?"完成":"否"}
        }, {
            field : "isSign",
            title : "合同签署",
            templet : function(data){return data.isSign?"完成":"否"}
        }, {
            field : "createTime",
            width : 160,
            title : "创建时间"
        }, {
            title : "操作",
            width : 150,
            align : "center",
            fixed : "right",
            toolbar : "#table-content-list"
        } ] ],
        page : !0,
        limit : 10,
        limits : [ 10, 15, 20, 25, 30 ],
        text: {none: '暂无相关数据'}
    }), tab.on("tool(LAY-web-list)", function(row) {
        if ("update" === row.event) {
        	parent.layer.open({
                type : 2,
                title : "编辑商户",
                content : layui.setter.base + "admin/customer/updatePage?id="
                    + row.data.id,
                maxmin : !0,
                area : [ '600px', '500px' ],
                btn : [ "确定", "取消" ],
                yes : function(index, layero) {
                    // 点击确认触发 iframe 内容中的按钮提交
                    layero.find('iframe').contents().find(
                        "#layuiadmin-app-form-edit").click();
                }
            });
            return;
        }

        if("view" == row.event){
        	parent.layer.open({
                type : 2,
                title : "商户详情",
                content : layui.setter.base + "admin/customer/view?id="
                    + row.data.id,
                maxmin : !0,
                area : [ '600px', '500px' ],
                btn : [ "确定", "取消" ],
                yes : function(index, layero) {
                    // 点击确认触发 iframe 内容中的按钮提交
                    layero.find('iframe').contents().find(
                        "#layuiadmin-app-form-edit").click();
                }
            });
            return;
        }

        if("uploadmerch" === row.event){
            console.log(row.data);

            parent.layer.open({
                type: 2
                ,title: '添加'
                ,content: 'admin/customer/uploadmerch?code='+ row.data.code + '&r=' + Math.random()
                ,maxmin: true
                ,area: ['80%', '90%']
                ,btn: ['确定', '取消']
                ,yes: function(index, layero){
                    //点击确认触发 iframe 内容中的按钮提交
                    layero.find('iframe').contents().find("#layuiadmin-app-form-edit").click();
                }
            });
        }

        if("more" === row.event){
            console.log(row.data);

            parent.layer.open({
                type: 2
                ,title: '更多'
                ,content: 'admin/customer/morecz?code='+ row.data.code + '&r=' + Math.random()
                ,maxmin: true
                ,area: ['80%', '90%']
                //,btn: ['', '']
                ,yes: function(index, layero){
                    //点击确认触发 iframe 内容中的按钮提交
                    layero.find('iframe').contents().find("#layuiadmin-app-form-edit").click();
                }
            });
        }

        if ("downmerch" === row.event) {
            console.log(row.data);
            layer.confirm("确定下载吗？", function(e) {
                console.log(row.data);
                window.location.href = layui.setter.base + "admin/customer/downmerch?code="
                    + row.data.code + "&r=" + Math.random();

                layer.close(e);
            });
            return;
        }


        if ("delete" === row.event) {
            layer.confirm("确定删除吗？", function(e) {
                console.log(row.data);
                // 请求删除接口
                layui.admin.req({
                    url : layui.setter.base + "admin/customer/delete?id="
                        + row.data.id + "&r=" + Math.random(),
                    data : null,
                    done : function(res) {
                        if (res.code !== 0) {
                            layer.msg(res.msg, {
                                icon : 2
                            });
                        } else {
                            layer.msg(res.msg, {
                                icon : 1
                            });
                            layui.table.reload('LAY-web-list'); // 重载表格
                            layer.close(e); // 再执行关闭
                        }
                    }
                });
            });
            return;
        }
    }), exports("customer", {})
});
